home *** CD-ROM | disk | FTP | other *** search
- #define DEBUG 0
- /*
- TOWNS囲碁棋譜記録プログラム ban.c
- 1992/07/06 久保田俊也
-
- */
- #include <stdio.h>
- #include <time.h>
- #include <string.h>
- #include "igo.h"
- #include "banx.h"
- #include "kiffile.h"
- #include "kifuctrl.h"
- #include "title.h"
-
- static int banx_uchiage2(int ichi);
- static int banx_gchk();
- static int banx_ginit();
- static int banx_do_judge();
- static int banx_gset(GCELL *g_ptr, int ichi, char *dameban);
- static int banx_gdel(GCELL *g_ptr);
- static int banx_easy_chk(int ichi);
- static int banx_easy_uchiage(int ichi);
- static int banx_dameadd(GCELL *g_ptr, int ichi);
- static int banx_bancelldel(int ichi);
- static int banx_get_damenum(GCELL *g_ptr);
- static int banx_henkan(GCELL *gcellp, char henkan_territory_iro);
-
- static int bansize, bansize2, up, down;
- static char ban[MAX_BANSIZE2];
- static char henkan_ban[MAX_BANSIZE2];
- static BANCELL bancell[MAX_BANSIZE2]; /* 盤の上の一路一路 */
- static GCELL init_gcell;
-
- int banx_init()
- {
- int i, j;
- BAN_TYPE ban_type;
-
- Debugprint("igo:banx_init() start!\n");
- ban_type = *title_bantype_read();
- if( ban_type.type == NORMAL){
- bansize = ban_type.size;
- bansize2 = (bansize+1)*(bansize+2)+1;
- up = -(bansize+1);
- down = (bansize+1);
- }
-
- ban_init(ban);
- banx_do_judge(ban);
-
- return 0;
- }
-
- int banx_end()
- {
-
- gcell_end();
- damecell_end();
-
- return 0;
- }
-
- int banx_handy_set( char current_ban[], int handy)
- {
-
- switch(handy){
- case '2' + 0:
- current_ban[96] = BLACK;
- current_ban[324] = BLACK;
- break;
-
- case '2' + 1:
- current_ban[96] = BLACK;
- current_ban[324] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 2:
- current_ban[84] = BLACK;
- current_ban[96] = BLACK;
- current_ban[324] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 3:
- current_ban[84] = BLACK;
- current_ban[96] = BLACK;
- current_ban[210] = BLACK;
- current_ban[324] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 4:
- current_ban[84] = BLACK;
- current_ban[96] = BLACK;
- current_ban[204] = BLACK;
- current_ban[216] = BLACK;
- current_ban[324] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 5:
- current_ban[84] = BLACK;
- current_ban[96] = BLACK;
- current_ban[204] = BLACK;
- current_ban[210] = BLACK;
- current_ban[216] = BLACK;
- current_ban[324] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 6:
- current_ban[84] = BLACK;
- current_ban[90] = BLACK;
- current_ban[96] = BLACK;
- current_ban[204] = BLACK;
- current_ban[216] = BLACK;
- current_ban[324] = BLACK;
- current_ban[330] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 7:
- current_ban[84] = BLACK;
- current_ban[90] = BLACK;
- current_ban[96] = BLACK;
- current_ban[204] = BLACK;
- current_ban[210] = BLACK;
- current_ban[216] = BLACK;
- current_ban[324] = BLACK;
- current_ban[330] = BLACK;
- current_ban[336] = BLACK;
- break;
-
- case '2' + 8:
- current_ban[84] = BLACK;
- current_ban[96] = BLACK;
- current_ban[324] = BLACK;
- break;
-
- default:
- break;
- }
- return 0;
- }
-
- int banx_uchiage( char current_ban[], int ichi, int *uchiage_number)
- {
- int i, j;
- int houkou[4];
- char input_color;
- char rejudge_flg;
- BANCELL *w_bancellp;
-
- *uchiage_number = 0;
- /* 着手放棄の時 エラ-にする */
- if(ichi == 0){
- return -1;
- }
-
- /* 入力画面がセ-ブしてある画面と同じか確認 */
- input_color = current_ban[ichi];
- current_ban[ichi] = BLANK;
-
- if(memcmp(ban, current_ban, sizeof(ban)) != 0){
- memcpy(ban, current_ban, sizeof(ban));
- banx_do_judge(ban);
- }
- ban[ichi] = input_color;
-
- /* 打ち上げるかどうかの判定 */
- houkou[0] = up;
- houkou[1] = LEFT;
- houkou[2] = RIGHT;
- houkou[3] = down;
-
- rejudge_flg = 0;
- for(i=0;i<4;i++){
- if(ban[ichi] != ban[ichi+houkou[i]] ){
- if(ban[ichi+houkou[i]] != BLANK && ban[ichi+houkou[i]]!=WALL){
- if(banx_get_damenum(bancell[ichi+houkou[i]].g_ptr) == 1 ){
- rejudge_flg =1;
- j = 0;
- w_bancellp = bancell[ichi+houkou[i]].g_ptr->c_ptr;
- do{
- j++;
- ban[w_bancellp-bancell] = BLANK;
- w_bancellp=w_bancellp->next;
- }while(w_bancellp!=bancell[ichi+houkou[i]].g_ptr->c_ptr);
- *uchiage_number += j;
- }
- }
- }
- }
-
- /* 再分析をするならば他の処理をする必要はない */
- if(rejudge_flg == 1){
- banx_uchiage2(ichi);
- }else{
- if(banx_easy_chk(ichi) == 0){
- banx_uchiage2(ichi);
- }else{
- banx_easy_uchiage(ichi);
- }
- }
-
- /* 画面の戻し処理 */
- memcpy(current_ban, ban, sizeof(ban));
-
- return 0;
- }
-
- /* グループのダメ(BLANKのみ)の数を数える */
- static int banx_get_damenum(GCELL *g_ptr)
- {
- DAMECELL *w_damecellp;
- int i;
-
- i=0;
- w_damecellp = g_ptr->dame_ptr;
- do{
- if(bancell[w_damecellp->ichi].g_ptr->iro == BLANK){
- i++;
- }
- w_damecellp = w_damecellp->next;
- }while(w_damecellp != g_ptr->dame_ptr);
-
- return i;
- }
-
- /* banx_uhciage2を使わずとも済む簡単な手かどうかの判断関数 */
- /* BLANKのグループが分割される可能性がなければ1を返す */
- static int banx_easy_chk(int ichi)
- {
- int houkou[8];
- char chk_area[8];
- int i;
- int brank_number, brank_number2;
-
- brank_number = brank_number2 = 0;
-
- houkou[0] = up+LEFT;
- houkou[1] = up;
- houkou[2] = up+RIGHT;
- houkou[3] = RIGHT;
- houkou[4] = down+RIGHT;
- houkou[5] = down;
- houkou[6] = down+LEFT;
- houkou[7] = LEFT;
-
- for(i=0;i<8;i++){
- chk_area[i] = ban[ichi+houkou[i]];
- if((i%2) == 1){
- if(ban[ichi+houkou[i]] == BLANK){
- brank_number++;
- }
- }
- }
-
- for(i=0;i<8;i++){
- if((i%2) == 1){
- if(ban[ichi+houkou[i]] != BLANK){
- chk_area[i-1] = chk_area[i] = chk_area[(i+1)%8] = WALL;
- }
- }
- }
-
- for(i=0;i<8;i++){
- if(chk_area[i] == BLANK){
- brank_number2++;
- }
- }
-
- if(brank_number == 0){
- return 0;
- }
-
- if((brank_number*2-1) == brank_number2){
- return 1;
- }
-
- return 0;
- }
-
- /* banx_uhciage2を使わずとも済む簡単な手の入力関数 */
- /* 対応しているのはBLANKのグループが分割されない場合 */
- static int banx_easy_uchiage(int ichi)
- {
- int i;
- int houkou[4];
-
- houkou[0] = up;
- houkou[1] = LEFT;
- houkou[2] = RIGHT;
- houkou[3] = down;
-
- /* 隣接する石の同色のグループの削除 */
- for(i=0;i<4;i++){
- if(ban[ichi] == ban[ichi+houkou[i]] && bancell[ichi+houkou[i]].g_ptr != NULL){
- banx_gdel(bancell[ichi+houkou[i]].g_ptr);
- }
- }
-
- /* ダメの追加 */
- banx_dameadd(bancell[ichi].g_ptr, ichi);
-
- /* territoryの削除 */
- banx_bancelldel(ichi);
-
- /* グループの作成 */
- bancell[ichi].g_ptr = NULL;
- banx_ginit(ichi);
-
- return 0;
- }
-
- /* ダメのグループへの追加 */
- static int banx_dameadd(GCELL *g_ptr, int ichi)
- {
- DAMECELL *w_damep;
-
- /* dame_ptr はNULL が設置してある */
- if(g_ptr->dame_ptr==NULL){
- w_damep = damecell_get();
- g_ptr->dame_ptr = w_damep;
- w_damep->next = w_damep;
- w_damep->ichi = ichi;
- }else{
- w_damep = damecell_get();
- w_damep->next = g_ptr->dame_ptr->next;
- g_ptr->dame_ptr->next = w_damep;
- w_damep->ichi = ichi;
- }
- /* ダメ数の計算 */
- g_ptr->dame_number++;
- /* territoty_iro の決定 */
- if(g_ptr->territory_iro != BLANK){
- if(g_ptr->territory_iro == WALL){
- g_ptr->territory_iro = ban[ichi];
- }else{
- if(g_ptr->territory_iro != ban[ichi]){
- g_ptr->territory_iro = BLANK;
- }
- }
- }
-
- return 0;
- }
-
- /* bancellのグループからの削除 */
- static int banx_bancelldel(int ichi)
- {
- BANCELL *w_bancellp;
-
- w_bancellp = bancell[ichi].g_ptr->c_ptr;
- if(w_bancellp == w_bancellp->next){
- printf("banx_bancelldel abnormal end !\n");
- }
-
- while(w_bancellp->next != &bancell[ichi]){
- w_bancellp = w_bancellp->next;
- }
- w_bancellp->next = bancell[ichi].next;
-
- /* 削除したbancellがグループの直下の場合c_ptrを変更する */
- if(bancell[ichi].g_ptr->c_ptr == &bancell[ichi]){
- bancell[ichi].g_ptr->c_ptr = w_bancellp->next;
- }
-
- return 0;
- }
-
- /* banx_uhciage の下請け関数 */
- static int banx_uchiage2(int ichi)
- {
- int houkou[5];
- int i;
-
- houkou[0] = up;
- houkou[1] = LEFT;
- houkou[2] = RIGHT;
- houkou[3] = down;
- houkou[4] = 0;
-
- for(i=0;i<5;i++){
- if(ban[ichi+houkou[i]] != WALL){
- if(bancell[ichi+houkou[i]].g_ptr != NULL){
- banx_gdel(bancell[ichi+houkou[i]].g_ptr);
- }
- }
- }
-
- for(i=0;i<5;i++){
- if(ban[ichi+houkou[i]] != WALL){
- banx_ginit(ichi+houkou[i]);
- }
- }
-
- return 0;
- }
-
- /* グループを削除する関数 */
- static int banx_gdel(GCELL *g_ptr)
- {
- DAMECELL *w_damep, *save_damep;
- GCELL *w_g_ptr;
- BANCELL *w_bancellp;
-
- /* 絶対満たす条件のはずだが一応確認 */
- if(g_ptr == NULL){
- printf("g_ptr abnormal!\n");
- }
-
- /* 一番最初の画面ではg_ptr->dame_ptr は NULL */
- if( g_ptr->dame_ptr != NULL){
- /* dame_ptrの解放 */
- w_damep = g_ptr->dame_ptr;
- do{
- save_damep = w_damep->next;
- damecell_free(w_damep);
- w_damep = save_damep;
- }while(w_damep != g_ptr->dame_ptr);
- }
-
- if(g_ptr->c_ptr != NULL){
- /* dame_ptrの解放 */
- w_bancellp = g_ptr->c_ptr;
- do{
- w_bancellp->g_ptr = NULL;
- w_bancellp = w_bancellp->next;
- }while(w_bancellp != g_ptr->c_ptr);
- }
-
- /* g_ptr の解放 */
- for(w_g_ptr = &init_gcell;w_g_ptr->next != g_ptr;w_g_ptr=w_g_ptr->next){
- ;
- }
- w_g_ptr->next = g_ptr->next;
- gcell_free(g_ptr);
-
- return 0;
- }
-
- /* グループを設定する際の初期化 banx_uchiage2 と banx_gchk で使用 */
- static int banx_ginit(int ichi)
- {
- char dameban[MAX_BANSIZE2];
-
- if(bancell[ichi].g_ptr == NULL){
- bancell[ichi].g_ptr = gcell_get();
- bancell[ichi].g_ptr->next = init_gcell.next;
- init_gcell.next = bancell[ichi].g_ptr;
-
- bancell[ichi].g_ptr->iro = ban[ichi];
- bancell[ichi].g_ptr->c_ptr = &bancell[ichi];
- bancell[ichi].next = &bancell[ichi];
- bancell[ichi].g_ptr->dame_ptr = NULL;
- bancell[ichi].g_ptr->dame_number = 0;
- /* territory_iroのクリアの意味でWALLを設定 */
- /* BLANK以外のエリアは特に何の色を設定しても問題ない ? */
- bancell[ichi].g_ptr->territory_iro=WALL;
- bancell[ichi].g_ptr->territory_number = 1;
-
- memset(dameban, 0, sizeof(dameban));
- banx_gset(bancell[ichi].g_ptr, ichi, dameban);
- }
-
- return 0;
- }
-
- /* 個々の石ダメごとにグループを設定 再帰関数 */
- static int banx_gset(GCELL *g_ptr, int ichi, char *dameban)
- {
- int houkou[4];
- int i;
-
- houkou[0] = up;
- houkou[1] = LEFT;
- houkou[2] = RIGHT;
- houkou[3] = down;
-
- for(i=0;i<4;i++){
- /* 個々の石をグループに設定 */
- if(ban[ichi+houkou[i]] == ban[ichi]){
- if(bancell[ichi+houkou[i]].g_ptr != g_ptr){
- bancell[ichi+houkou[i]].g_ptr = g_ptr;
- bancell[ichi+houkou[i]].next = bancell[ichi].next;
- bancell[ichi].next = &bancell[ichi+houkou[i]];
- g_ptr->territory_number++;
- banx_gset(g_ptr, ichi+houkou[i], dameban);
- }
- }else{
- /* グループごとのダメの設定 */
- if(ban[ichi+houkou[i]]!=WALL && dameban[ichi+houkou[i]] != 1){
- dameban[ichi+houkou[i]] = 1;
- banx_dameadd(g_ptr, ichi+houkou[i]);
- }
- }
- }
- return 0;
- }
-
- int banx_judge(char current_ban[])
- {
- int i;
-
- /* 入力画面がセ-ブしてある画面と同じか確認 */
- for(i=0;i<MAX_BANSIZE2;i++){
- ban[i] = current_ban[i];
- }
-
- banx_do_judge(ban);
-
- /* 形勢判断の時は表示する画面を設定 */
- for(i=0;i<MAX_BANSIZE2;i++){
- henkan_ban[i] = ban[i];
- }
-
- return 0;
- }
-
- static int banx_do_judge(char current_ban[])
- {
- int i;
-
- for(i=0;i<bansize2;i++){
- bancell[i].g_ptr = NULL;
- bancell[i].next = NULL;
- }
- gcell_init();
- damecell_init();
- init_gcell.next = &init_gcell;
-
- banx_gchk();
-
- return 0;
- }
-
- /* グル-プを設定してバンセルを位置づける */
- static int banx_gchk()
- {
- int i, j;
- int ichi;
-
- /* グル-プの判別 */
- for(i=1;i<bansize+1;i++){
- for(j=1;j<bansize+1;j++){
- ichi = i*(bansize+1) + j;
- banx_ginit(ichi);
- }
- }
-
- return 0;
- }
-
- /* 盤面にデ-タを表示する */
- char *banx_judgedisp()
- {
- BANCELL *w_ptr;
- GCELL *cur_g_ptr;
-
- for(cur_g_ptr=init_gcell.next;cur_g_ptr!=&init_gcell;
- cur_g_ptr=cur_g_ptr->next){
- switch (cur_g_ptr->iro){
- case BLACK:
- case WHITE:
- w_ptr=cur_g_ptr->c_ptr;
- do{
- if(cur_g_ptr->henkan_territory_iro==BLANK){
- henkan_ban[w_ptr-bancell] = cur_g_ptr->iro;
- }else{
- if(cur_g_ptr->iro == BLACK){
- henkan_ban[w_ptr-bancell]=BLACK_CAPTURE;
- }else{
- henkan_ban[w_ptr-bancell]=WHITE_CAPTURE;
- }
- }
- w_ptr=w_ptr->next;
- }while(w_ptr!=cur_g_ptr->c_ptr);
- break;
- case BLANK:
- w_ptr=cur_g_ptr->c_ptr;
- do{
- if(henkan_ban[w_ptr-bancell]!=WALL_TERRITORY){
- if(cur_g_ptr->henkan_territory_iro==BLANK){
- if(cur_g_ptr->territory_iro==BLACK)
- henkan_ban[w_ptr-bancell]=BLACK_TERRITORY;
- else if(cur_g_ptr->territory_iro==WHITE){
- henkan_ban[w_ptr-bancell]=WHITE_TERRITORY;
- }else{
- henkan_ban[w_ptr-bancell]=BLANK;
- }
- }else{
- if(cur_g_ptr->henkan_territory_iro==BLACK)
- henkan_ban[w_ptr-bancell]=BLACK_TERRITORY;
- else if(cur_g_ptr->henkan_territory_iro==WHITE){
- henkan_ban[w_ptr-bancell]=WHITE_TERRITORY;
- }else{
- henkan_ban[w_ptr-bancell]=BLANK;
- }
- }
- }
- w_ptr=w_ptr->next;
- }while(w_ptr!=cur_g_ptr->c_ptr);
- break;
- default: break;
- }
- }
-
- #if DEBUG
- int i;
- char iro_str[16];
- char debug_str[100];
-
- for(i=0;i<MAX_BANSIZE2;i++){
- switch (henkan_ban[i]){
- case BLANK: strcpy(iro_str, "BLANK"); break;
- case WHITE: strcpy(iro_str, "WHITE"); break;
- case BLACK: strcpy(iro_str, "BLACK"); break;
- case WHITE_TERRITORY: strcpy(iro_str, "WHITE_TERRITORY"); break;
- case BLACK_TERRITORY: strcpy(iro_str, "BLACK_TERRITORY"); break;
- case WHITE_CAPTURE: strcpy(iro_str, "WHITE_CAPTURE"); break;
- case BLACK_CAPTURE: strcpy(iro_str, "BLACK_CAPTURE"); break;
- default: break;
- }
- sprintf(debug_str, "henkan_ban[%d] = %s\n", i, iro_str);
- debugprint(debug_str);
- }
- #endif
-
- return henkan_ban;
- }
-
- /* 地の数デ-タを表示する */
- int banx_territory(int *black_t_number, int *white_t_number)
- {
- GCELL *current_g_ptr;
-
- *black_t_number=0;
- *white_t_number=0;
- for(current_g_ptr=init_gcell.next;current_g_ptr!=&init_gcell;
- current_g_ptr=current_g_ptr->next){
- if(current_g_ptr->henkan_territory_iro==BLANK){
- switch (current_g_ptr->territory_iro){
- case BLACK:
- *black_t_number+=current_g_ptr->territory_number;
- break;
- case WHITE:
- *white_t_number+=current_g_ptr->territory_number;
- break;
- default: break;
- }
- }else{
- switch (current_g_ptr->iro){
- case BLACK:
- *white_t_number+=current_g_ptr->territory_number*2;
- break;
- case WHITE:
- *black_t_number+=current_g_ptr->territory_number*2;
- break;
- case BLANK:
- if(current_g_ptr->henkan_territory_iro==BLACK){
- *black_t_number+=current_g_ptr->territory_number;
- }else{
- *white_t_number+=current_g_ptr->territory_number;
- }
- break;
- default: break;
- }
- }
- }
-
- return 0;
-
- }
-
- /* 形勢判断を行っている時の盤の操作を行う */
- int banx_put( int ichi)
- {
- DAMECELL *w_ptr;
- char henkan_territory_iro; /* 変換後の領地の所有者 */
-
- if(ban[ichi]==BLANK){
- if(henkan_ban[ichi]==WALL_TERRITORY){
- henkan_ban[ichi]=BLANK;
- ++(bancell[ichi].g_ptr->territory_number);
- }else{
- henkan_ban[ichi]=WALL_TERRITORY;
- --(bancell[ichi].g_ptr->territory_number);
- }
- }else{
- if(bancell[ichi].g_ptr->henkan_territory_iro==BLANK){
- henkan_territory_iro=1-bancell[ichi].g_ptr->iro;
- }else{
- henkan_territory_iro=BLANK;
- }
- bancell[ichi].g_ptr->henkan_territory_iro=henkan_territory_iro;
- if((w_ptr=bancell[ichi].g_ptr->dame_ptr)!=NULL){
- do{
- banx_henkan(bancell[w_ptr->ichi].g_ptr, henkan_territory_iro);
- w_ptr=w_ptr->next;
- }while(w_ptr!=bancell[ichi].g_ptr->dame_ptr);
- }
- }
-
- return 0;
-
- }
-
- /* 指定されたグル-プと隣接したグル-プの取られ石かそうでないかの変換 */
- static int banx_henkan(GCELL *gcellp, char henkan_territory_iro)
- {
- DAMECELL *w_ptr;
-
- if(henkan_territory_iro==BLANK){
- if(gcellp->henkan_territory_iro==BLANK){
- return 0;
- }
- gcellp->henkan_territory_iro=henkan_territory_iro;
- }else{
- if(gcellp->iro==henkan_territory_iro
- || gcellp->henkan_territory_iro==henkan_territory_iro){
- return 0;
- }
- gcellp->henkan_territory_iro=henkan_territory_iro;
-
- }
-
- if((w_ptr=gcellp->dame_ptr)!=NULL){
- do{
- banx_henkan(bancell[w_ptr->ichi].g_ptr, henkan_territory_iro);
- w_ptr=w_ptr->next;
- }while(w_ptr!=gcellp->dame_ptr);
- }
- return 0;
- }
-
- int banx_debugprint()
- {
- static int i = 0;
- FILE *fp;
- GCELL *cur_g_ptr;
- BANCELL *w_ptr;
- DAMECELL *w_damep;
-
- if(++i < 67){
- return -1;
- }
-
- if((fp=fopen("debug.txt","a"))==NULL){
- printf("debug txt open error!\n");
- return -1;
- }
-
- fprintf(fp, "banx_debugprint(%d)!\n", i);
- for(cur_g_ptr=init_gcell.next;cur_g_ptr!=&init_gcell;
- cur_g_ptr=cur_g_ptr->next){
- fprintf(fp, "g_ptr = %d\n", cur_g_ptr);
- fprintf(fp, "g_ptr.iro = %d\n", cur_g_ptr->iro);
- fprintf(fp, "g_ptr.territory_number = %d\n", cur_g_ptr->territory_number);
- /*
- if(cur_g_ptr->iro != BLANK){
- */
- w_ptr=cur_g_ptr->c_ptr;
- do{
- fprintf(fp, " bancell ichi = (%d, %d)\n", (w_ptr - bancell)%(bansize+1), (w_ptr -bancell)/(bansize+1));
- w_ptr=w_ptr->next;
- }while(w_ptr!=cur_g_ptr->c_ptr);
- /*
- }
- */
- fprintf(fp, "g_ptr.dame_number = %d\n", cur_g_ptr->dame_number);
- if(cur_g_ptr->dame_ptr==NULL){
- ;
- }else{
- w_damep=cur_g_ptr->dame_ptr;
- do{
- fprintf(fp, " damecell ichi = (%d, %d)\n", (w_damep->ichi)%(bansize+1), (w_damep->ichi)/(bansize+1));
- w_damep=w_damep->next;
- }while(w_damep!=cur_g_ptr->dame_ptr);
- }
-
- fprintf(fp, "g_ptr.territory_iro = %d\n", cur_g_ptr->territory_iro);
- fprintf(fp, "g_ptr.henkan_territory_iro = %d\n\n", cur_g_ptr->henkan_territory_iro);
- }
-
- fprintf(fp, "banx_debugprint end! \n\n");
-
- fclose(fp);
-
- return 0;
- }
-
-